home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / bstfiles.zoo / phaip.bst < prev    next >
Lisp/Scheme  |  1992-06-30  |  61KB  |  1,886 lines

  1. % BibTeX styles for various physics journals (27-Feb-1990).
  2. % This file, physics.btx, is based on the file btxbst.doc.
  3.     % Please notify Charles Karney (Karney@Princeton.EDU)
  4.     % of any bugs, improvements, etc.
  5. % Run this file through cpp to get specific versions.  I have written
  6. % a version of cpp within Emacs.  To access it put
  7. %    (autoload 'cpp "tex$bibtex:cpp"        ; Use cpp for BibTeX styles
  8. %          "C preprocessor"
  9. %          t)
  10. % into your .emacs file.  Read in this file with
  11. %    emacs tex$bibtex:physics.btx
  12. % and run cpp with e.g.,
  13. %    M-x cpp <ret> aip <ret>
  14. % Save the resulting file to tex$latex:aip.bst.
  15. % To accomodate the variations we need (in addition to the definitions below)
  16. %    ATIT_SUPPRESS:    do not include the titles of journal articles
  17. %    NAME_INVERT:    put the initials last
  18. %    NAME_UPPER:    convert names to all caps.
  19. %    MONTH_SUPPRESS:    do not include months in journal articles
  20. %    PAREN_DATE:    dates go in parens in journal articles
  21. %    DATE_FIRST:    dates go before page numbers
  22. %    VOLUME_SPACE:    volume set off with space (not colon)
  23. %    NUM_SUPPRESS:    do not include numbers in journal articles
  24. %    BOLD_VOL:    volume numbers in bold face in journal articles
  25. %    BRACKET_NOTE:    notes in brackets
  26. %    PAGE_START_J:    include only starting page for journal articles
  27. %    PAGE_START_O:    include only starting page for other entries
  28. %    PAGE_ABBREV:    abbreviate page to p. and pages to pp.
  29. %    PHYSICS_JOUR:    include abbreviations for Physics journals
  30. %    COMMA_DELIMIT:    use comma (instead of period) to divide a citation
  31. %    NOTE_SUPPRESS:    suppress the note
  32. %    MAX_NAMES:    max number of authors before using et al (0 = infinity)
  33. %    MIN_NAMES:    number of authors to list with et al.
  34. %    EDIT_VAR:    use "edited by ..." instead of "..., editors"
  35. %    RMP_LABELS:    create RMP-style labels
  36. %    KEY_CITE:    use key as label
  37. %    NAMED_REFS:    use (Smith, 1988) style of citations
  38. %    CSC_NAMES:    names set in caps and small caps
  39. %    JOUR_DEEMPH:    don't emphasize journal name
  40. %    ETAL_EMPH:    emphasize et al.
  41. %    ALT_INCOLL    alternate ordering of fields in incollections
  42. % These are all boolean (0 or 1) except for MAX_NAMES and MIN_NAMES.
  43. % These need to satisfy 0 <= MIN_NAMES <= MAX_NAMES.
  44. % The rule here is that if all these are defined to be zero, we revert to
  45. % the standard styles.  For that reason we initialize them all to 0.
  46. % These are the original macros
  47.     % For American Institute of Physics Journals
  48. % This is the start of btxbst.doc
  49. % BibTeX `plain' family
  50.     % version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
  51.     % Copyright (C) 1985, all rights reserved.
  52.     % Copying of this file is authorized only if either
  53.     % (1) you make absolutely no changes to your copy, including name, or
  54.     % (2) if you do make changes, you name it something other than
  55.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  56.     % This restriction helps ensure that all standard styles are identical.
  57.     % The file btxbst.doc has the documentation for this style.
  58. % Please notify Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU) of any bugs in
  59. % these standard styles or in this documentation file.
  60. %
  61. % This is file btxbxt.doc; it helps document bibliography styles,
  62. % and is also a template file that you can use to make
  63. % several different style files, if you have access to a C preprocessor.
  64. % For example, the standard styles were made by doing something like
  65. %    cpp -P -DPLAIN btxbst.doc plain.txt
  66. %    cpp -P -DUNSRT btxbst.doc unsrt.txt
  67. %    cpp -P -DALPHA btxbst.doc alpha.txt
  68. %    cpp -P -DABBRV btxbst.doc abbrv.txt
  69. % and then renaming after removing unwanted comments and blank lines.
  70. % If you don't have access,
  71. % you can edit this file by hand to imitate the preprocessor,
  72. % with the following explanation of the C preprocessor constructs used here.
  73. %
  74. % The output of the preprocessor is the same as the input, except that certain
  75. % lines will be excluded (and some blank lines will be added).  The sequence
  76. %    #if VAR
  77. %        lines to be included when VAR is not zero
  78. %    #else
  79. %        lines to be included when VAR is zero
  80. %    #endif
  81. % (with the #-signs appearing in column 1) means that one set or the other of
  82. % the lines are to be included depending on the value of VAR.
  83. % The #else part is optional.  Comments can be added after #else and #endif.
  84. % Variables can be set by
  85. %    #define VAR value
  86. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  87. % to see if it has none.
  88. % Another #if form used in this file is #if !VAR, which includes the lines
  89. % after the #if only if VAR is zero.
  90. %
  91. % Convention: Use all uppercase identifiers for these preprocessor variables
  92. % so you can spot them easily
  93. %
  94. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  95. % or ABBRV (though PLAIN will be used by default if none is given),
  96. % and the following lines will set various boolean variables to control the
  97. % various lines that are chosen from the rest of the file.
  98. % Each boolean variable should be set true (1) or false (0) in each style.
  99. % Here are the current variables, and their meanings:
  100. %    0:    an alphabetic label is used (if false then a numeric
  101. %                label is used)
  102. %    0:        the entries should be sorted by label (if nonnumeric)
  103. %                and other info, like authors (if false, then
  104. %                entries remain in order of occurrence)
  105. %    0:    the authors, editors, etc., get the full names as
  106. %                given in the bibliography file (if false, the first
  107. %                names become initials)
  108. %    1:    titles of non-"books" (e.g., articles) should be
  109. %                converted to lower-case, except the first letter or
  110. %                first letter after a colon
  111. %                (if false then they appear as in the database)
  112. %    0:    months are spelled out in full (if false, then
  113. %                they're abbreviated)
  114. %    0:    macro journal names are spelled out in full
  115. %                (if false then they are abbreviated, currently
  116. %                as they appear in ACM publications)
  117. %#        define PLAIN 1
  118. %
  119. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  120. %    in "A Handbook for Scholars".  Book-like titles are italicized
  121. %    (emphasized) and non-book titles are converted to sentence
  122. %    capitilization (and not enclosed in quotes).
  123. %    This file outputs a \newblock between major blocks of an entry
  124. %    (the name \newblock is analogous to the names \newline and \newpage)
  125. %    so that the user can obtain an "open" format, which has a line break
  126. %    before each block and lines after the first are indented within blocks,
  127. %    by giving the optional \documentstyle argument `openbib';
  128. %    The default is the "closed" format---blocks runs together.
  129. %
  130. %   Citation alphabetic label format:
  131. %        [Knu73] for single author (or editor or key)
  132. %        [AHU83] (first letters of last names) for multiple authors
  133. %
  134. %   Citation label numberic format:
  135. %        [number]
  136. %
  137. %   Reference list ordering for sorted, alphabetic lables:
  138. %        alphabetical by citation label, then by author(s) or whatever
  139. %        passes for author in the absence of one, then by year,
  140. %        then title
  141. %
  142. %   Reference list ordering for sorted, numeric lables:
  143. %        alphabetical by author(s) or whatever passes
  144. %        for author in the absence of one, then by year, then title
  145. %
  146. %   Reference list ordering for unsorted:
  147. %        by the order cited in the text
  148. %
  149. %   History
  150. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  151. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  152. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik.
  153. %    2/17/85    (HWT)    Template file and other standard styles made.
  154. %    3/28/85    (OP)    First release, version 0.98b for BibTeX 0.98f.
  155. %    5/ 9/85    (OP)    Version 0.98c for BibTeX 0.98i:
  156. %            fixed Theoretical Computer Science macro name;
  157. %            fixed the format.vol.num.pages function.
  158. %    1/24/88    (OP)    Version 0.99a for BibTeX 0.99a, main changes:
  159. %            assignment operator (:=) arguments reversed;
  160. %            the preamble$ function outputs the database PREAMBLE;
  161. %            entry.max$ and global.max$ (built-in) variables replace
  162. %            entry.string.max and global.string.max functions;
  163. %            alphabetizing by year then title, not just title;
  164. %            many unnecessary ties removed; \it ==> \em;
  165. %            the `alpha' style uses a superscripted `+' instead of a
  166. %            `*' for unnamed names in constructing the label;
  167. %            the `abbrv' style now uses "Mar." and "Sept.";
  168. %            the functions calc.label and presort now look at just
  169. %            the fields they're supposed to;
  170. %            BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
  171. %            INBOOK and INCOLLECTION take an optional type (e.g.
  172. %            type = "Section"), overriding the default "chapter";
  173. %            BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
  174. %            either volume or number, not just volume;
  175. %            INCOLLECTION now allows an edition and series field;
  176. %            PROCEEDINGS and INPROCEEDINGS now use the address field
  177. %            to tell where a conference was held;
  178. %            INPROCEEDINGS and PROCEEDINGS now allow either volume
  179. %            or number, and also a series field;
  180. %            MASTERSTHESIS and PHDTHESIS accept types other than
  181. %            "Master's thesis" and "PhD thesis";
  182. %            UNPUBLISHED now outputs, in one block, note then date;
  183. %            MANUAL now prints out the organization in
  184. %            the first block if the author field is empty;
  185. %            MISC can't be empty---it requires some optional field.
  186. %    3/23/88    (OP)    Version 0.99b for BibTeX 0.99c---changed the three
  187. %            erroneous occurrences of `cite ' to `cite$ '; this
  188. %            change didn't affect the four standard styles, so the
  189. %            0.99a versions of those styles are still current.
  190. %
  191. % The ENTRY declaration
  192. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  193. %   but no fullauthor or editors fields because BibTeX does name handling.
  194. %   The annote field is commented out here because this family doesn't
  195. %   include an annotated bibliography style.  And in addition to the fields
  196. %   listed here, BibTeX has a built-in crossref field, explained later.
  197. ENTRY
  198. % Fields:
  199.   { address
  200. %        Usually the address of a publisher or other type of organization.
  201. %        Put information in this field only if it helps the reader find the
  202. %        thing---for example you should omit the address of a major
  203. %        publisher entirely.  For a PROCEEDINGS or an INPROCEEDINGS,
  204. %        however, it's the address of the conference; for those two entry
  205. %        types, include the publisher's or organization's address, if
  206. %        necessary, in the publisher or organization field.
  207. %    annote
  208. %        Long annotation---for annotated bibliographies (begins sentence).
  209.     author
  210. %        Name(s) of author(s), in BibTeX name format.
  211.     booktitle
  212. %        Book title when the thing being referenced isn't the whole book.
  213. %        For book entries, the title field should be used instead.
  214.     chapter
  215. %        Chapter (or section or whatever) number.
  216.     edition
  217. %        Edition of a book---should be an ordinal (e.g., "Second").
  218.     editor
  219. %        Name(s) of editor(s), in BibTeX name format.
  220. %        If there is also an author field, then the editor field should be
  221. %        for the book or collection that the work appears in.
  222.     howpublished
  223. %         How something strange has been published (begins sentence).
  224.     institution
  225. %        Sponsoring institution of a technical report.
  226.     journal
  227. %        Journal name (macros are provided for many).
  228.     key
  229. %        Alphabetizing, labeling, and cross-referencing key
  230. %        (needed when an entry has no author or editor).
  231.     month
  232. %        Month (macros are provided).
  233.     note
  234. %        To help the reader find a reference (begins sentence).
  235.     number
  236. %        Number of a journal or technical report, or of a work in a series.
  237.     organization
  238. %        Organization sponsoring a conference (or publishing a manual); if
  239. %        the editor (or author) is empty, and if the organization produces
  240. %        an awkward label or cross reference, you should put appropriately
  241. %        condensed organization information in the key field as well.
  242.     pages
  243. %        Page number or numbers (use `--' to separate a range, use `+'
  244. %        to indicate pages following that don't form a simple range).
  245.     publisher
  246. %        Publisher name.
  247.     school
  248. %        School name (for theses).
  249.     series
  250. %        The name of a series or set of books.
  251. %        An individual book will will also have it's own title.
  252.     title
  253. %        The title of the thing you're referred to.
  254.     type
  255. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  256. %        the default "Technical Report"; or, similarly, the type of a
  257. %        thesis; or of a part of a book.
  258.     volume
  259. %        The volume number of a journal or multivolume work.
  260.     year
  261. %        The year should contain only numerals (technically, it should end
  262. %        with four numerals, after purification; doesn't a begin sentence).
  263.   }
  264. % There are no integer entry variables
  265.   {}
  266. % These string entry variables are used to form the citation label.
  267. % In a storage pinch, sort.label can be easily computed on the fly.
  268.   { label }
  269. % Each entry function starts by calling output.bibitem, to write the
  270. % \bibitem and its arguments to the .BBL file.  Then the various fields
  271. % are formatted and printed by output or output.check.  Those functions
  272. % handle the writing of separators (commas, periods, \newblock's),
  273. % taking care not to do so when they are passed a null string.
  274. % Finally, fin.entry is called to add the final period and finish the
  275. % entry.
  276. %
  277. % A bibliographic reference is formatted into a number of `blocks':
  278. % in the open format, a block begins on a new line and subsequent
  279. % lines of the block are indented.  A block may contain more than
  280. % one sentence (well, not a grammatical sentence, but something to
  281. % be ended with a sentence ending period).  The entry functions should
  282. % call new.block whenever a block other than the first is about to be
  283. % started.  They should call new.sentence whenever a new sentence is
  284. % to be started.  The output functions will ensure that if two
  285. % new.sentence's occur without any non-null string being output between
  286. % them then there won't be two periods output.  Similarly for two
  287. % successive new.block's.
  288. %
  289. % The output routines don't write their argument immediately.
  290. % Instead, by convention, that argument is saved on the stack to be
  291. % output next time (when we'll know what separator needs to come
  292. % after it).  Meanwhile, the output routine has to pop the pending
  293. % output off the stack, append any needed separator, and write it.
  294. %
  295. % To tell which separator is needed, we maintain an output.state.
  296. % It will be one of these values:
  297. %    before.all        just after the \bibitem
  298. %    mid.sentence        in the middle of a sentence: comma needed
  299. %                    if more sentence is output
  300. %    after.sentence        just after a sentence: period needed
  301. %    after.block        just after a block (and sentence):
  302. %                    period and \newblock needed.
  303. % Note: These styles don't use after.sentence
  304. %
  305. % VAR: output.state : INTEGER        -- state variable for output
  306. %
  307. % The output.nonnull function saves its argument (assumed to be nonnull)
  308. % on the stack, and writes the old saved value followed by any needed
  309. % separator.  The ordering of the tests is decreasing frequency of
  310. % occurrence.
  311. %
  312. % output.nonnull(s) ==
  313. %  BEGIN
  314. %    s := argument on stack
  315. %    if output.state = mid.sentence then
  316. %        write$(pop() * ", ")
  317. %          -- "pop" isn't a function: just use stack top
  318. %    else
  319. %        if output.state = after.block then
  320. %        write$(add.period$(pop()))
  321. %        newline$
  322. %        write$("\newblock ")
  323. %        else
  324. %        if output.state = before.all then
  325. %            write$(pop())
  326. %        else        -- output.state should be after.sentence
  327. %            write$(add.period$(pop()) * " ")
  328. %        fi
  329. %        fi
  330. %        output.state := mid.sentence
  331. %    fi
  332. %    push s on stack
  333. %  END
  334. %
  335. % The output function calls output.nonnull if its argument is non-empty;
  336. % its argument may be a missing field (thus, not necessarily a string)
  337. %
  338. % output(s) ==
  339. %  BEGIN
  340. %    if not empty$(s) then output.nonnull(s)
  341. %    fi
  342. %  END
  343. %
  344. % The output.check function is the same as the output function except that, if
  345. % necessary, output.check warns the user that the t field shouldn't be empty
  346. % (this is because it probably won't be a good reference without the field;
  347. % the entry functions try to make the formatting look reasonable even when
  348. % such fields are empty).
  349. %
  350. % output.check(s,t) ==
  351. %  BEGIN
  352. %    if empty$(s) then
  353. %        warning$("empty " * t * " in " * cite$)
  354. %    else output.nonnull(s)
  355. %    fi
  356. %  END
  357. %
  358. % The output.bibitem function writes the \bibitem for the current entry
  359. % (the label should already have been set up), and sets up the separator
  360. % state for the output functions.  And, it leaves a string on the stack
  361. % as per the output convention.
  362. %
  363. % output.bibitem ==
  364. %  BEGIN
  365. %    newline$
  366. %    write$("\bibitem[")    % for alphabetic labels,
  367. %    write$(label)        % these three lines
  368. %    write$("]{")        % are used
  369. %    write$("\bibitem{")        % this line for numeric labels
  370. %    write$(cite$)
  371. %    write$("}")
  372. %    push "" on stack
  373. %    output.state := before.all
  374. %  END
  375. %
  376. % The fin.entry function finishes off an entry by adding a period to the
  377. % string remaining on the stack.  If the state is still before.all
  378. % then nothing was produced for this entry, so the result will look bad,
  379. % but the user deserves it. (We don't omit the whole entry because the
  380. % entry was cited, and a bibitem is needed to define the citation label.)
  381. %
  382. % fin.entry ==
  383. %  BEGIN
  384. %    write$(add.period$(pop()))
  385. %    newline$
  386. %  END
  387. %
  388. % The new.block function prepares for a new block to be output, and
  389. % new.sentence prepares for a new sentence.
  390. %
  391. % new.block ==
  392. %  BEGIN
  393. %    if output.state <> before.all then
  394. %        output.state := after.block
  395. %    fi
  396. %  END
  397. %
  398. % new.sentence ==
  399. %  BEGIN
  400. %    if output.state <> after.block then
  401. %        if output.state <> before.all then
  402. %        output.state :=  after.sentence
  403. %        fi
  404. %    fi
  405. %  END
  406. %
  407. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  408. FUNCTION {init.state.consts}
  409. { #0 'before.all :=
  410.   #1 'mid.sentence :=
  411.   #2 'after.sentence :=
  412.   #3 'after.block :=
  413. }
  414. % the variables s and t are temporary string holders
  415. STRINGS { s t }
  416. FUNCTION {output.nonnull}
  417. { 's :=
  418.   output.state mid.sentence =
  419.     { ", " * write$ }
  420.     { output.state after.block =
  421.     { "," * write$
  422.       newline$
  423.       "\newblock " write$
  424.     }
  425.     { output.state before.all =
  426.         'write$
  427.         { add.period$ " " * write$ }
  428.       if$
  429.     }
  430.       if$
  431.       mid.sentence 'output.state :=
  432.     }
  433.   if$
  434.   s
  435. }
  436. FUNCTION {output}
  437. { duplicate$ empty$
  438.     'pop$
  439.     'output.nonnull
  440.   if$
  441. }
  442. FUNCTION {output.check}
  443. { 't :=
  444.   duplicate$ empty$
  445.     { pop$ "empty " t * " in " * cite$ * warning$ }
  446.     'output.nonnull
  447.   if$
  448. }
  449. FUNCTION {output.bibitem}
  450. { newline$
  451.   "\bibitem{" write$
  452.   cite$ write$
  453.   "}" write$
  454.   newline$
  455.   ""
  456.   before.all 'output.state :=
  457. }
  458. % This function finishes all entries.
  459. FUNCTION {fin.entry}
  460. { add.period$
  461.   write$
  462.   newline$
  463. }
  464. FUNCTION {new.block}
  465. { output.state before.all =
  466.     'skip$
  467.     { after.block 'output.state := }
  468.   if$
  469. }
  470. FUNCTION {new.sentence}
  471. { skip$
  472. }
  473. % These three functions pop one or two (integer) arguments from the stack
  474. % and push a single one, either 0 or 1.
  475. % The 'skip$ in the `and' and `or' functions are used because
  476. % the corresponding if$ would be idempotent
  477. FUNCTION {not}
  478. {   { #0 }
  479.     { #1 }
  480.   if$
  481. }
  482. FUNCTION {and}
  483. {   'skip$
  484.     { pop$ #0 }
  485.   if$
  486. }
  487. FUNCTION {or}
  488. {   { pop$ #1 }
  489.     'skip$
  490.   if$
  491. }
  492. % Sometimes we begin a new block only if the block will be big enough.  The
  493. % new.block.checka function issues a new.block if its argument is nonempty;
  494. % new.block.checkb does the same if either of its TWO arguments is nonempty.
  495. FUNCTION {new.block.checka}
  496. { empty$
  497.     'skip$
  498.     'new.block
  499.   if$
  500. }
  501. FUNCTION {new.block.checkb}
  502. { empty$
  503.   swap$ empty$
  504.   and
  505.     'skip$
  506.     'new.block
  507.   if$
  508. }
  509. % The new.sentence.check functions are analogous.
  510. FUNCTION {new.sentence.checka}
  511. { empty$
  512.     'skip$
  513.     'new.sentence
  514.   if$
  515. }
  516. FUNCTION {new.sentence.checkb}
  517. { empty$
  518.   swap$ empty$
  519.   and
  520.     'skip$
  521.     'new.sentence
  522.   if$
  523. }
  524. % Here are some functions for formatting chunks of an entry.
  525. % By convention they either produce a string that can be followed by
  526. % a comma or period (using add.period$, so it is OK to end in a period),
  527. % or they produce the null string.
  528. %
  529. % A useful utility is the field.or.null function, which checks if the
  530. % argument is the result of pushing a `missing' field (one for which no
  531. % assignment was made when the current entry was read in from the database)
  532. % or the result of pushing a string having no non-white-space characters.
  533. % It returns the null string if so, otherwise it returns the field string.
  534. % Its main (but not only) purpose is to guarantee that what's left on the
  535. % stack is a string rather than a missing field.
  536. %
  537. % field.or.null(s) ==
  538. %  BEGIN
  539. %    if empty$(s) then return ""
  540. %    else return s
  541. %  END
  542. %
  543. % Another helper function is emphasize, which returns the argument emphazised,
  544. % if that is non-empty, otherwise it returns the null string.  Italic
  545. % corrections aren't used, so this function should be used when punctation
  546. % will follow the result.
  547. %
  548. % emphasize(s) ==
  549. %  BEGIN
  550. %    if empty$(s) then return ""
  551. %    else return "{\em " * s * "}"
  552. %
  553. % The format.names function formats the argument (which should be in
  554. % BibTeX name format) into "First Von Last, Junior", separated by commas
  555. % and with an "and" before the last (but ending with "et~al." if the last
  556. % of multiple authors is "others").  This function's argument should always
  557. % contain at least one name.
  558. %
  559. % VAR: nameptr, namesleft, numnames: INTEGER
  560. % pseudoVAR: nameresult: STRING        (it's what's accumulated on the stack)
  561. %
  562. % format.names(s) ==
  563. %  BEGIN
  564. %    nameptr := 1
  565. %    numnames := num.names$(s)
  566. %    namesleft := numnames
  567. %    while namesleft > 0
  568. %      do
  569. %                % for full names:
  570. %        t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
  571. %                % for abbreviated first names:
  572. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  573. %        if nameptr > 1 then
  574. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  575. %        else if numnames > 2
  576. %               then nameresult := nameresult * ","
  577. %             fi
  578. %             if t = "others"
  579. %               then nameresult := nameresult * " et~al."
  580. %               else nameresult := nameresult * " and " * t
  581. %             fi
  582. %        fi
  583. %        else nameresult := t
  584. %        fi
  585. %        nameptr := nameptr + 1
  586. %        namesleft := namesleft - 1
  587. %      od
  588. %    return nameresult
  589. %  END
  590. %
  591. % The format.authors function returns the result of format.names(author)
  592. % if the author is present, or else it returns the null string
  593. %
  594. % format.authors ==
  595. %  BEGIN
  596. %    if empty$(author) then return ""
  597. %    else return format.names(author)
  598. %    fi
  599. %  END
  600. %
  601. % Format.editors is like format.authors, but it uses the editor field,
  602. % and appends ", editor" or ", editors"
  603. %
  604. % format.editors ==
  605. %  BEGIN
  606. %    if empty$(editor) then return ""
  607. %    else
  608. %        if num.names$(editor) > 1 then
  609. %        return format.names(editor) * ", editors"
  610. %        else
  611. %        return format.names(editor) * ", editor"
  612. %        fi
  613. %    fi
  614. %  END
  615. %
  616. % Other formatting functions are similar, so no "comment version" will be
  617. % given for them.
  618. %
  619. % The `pop$' in this function gets rid of the duplicate `empty' value and
  620. % the `skip$' returns the duplicate field value
  621. FUNCTION {field.or.null}
  622. { duplicate$ empty$
  623.     { pop$ "" }
  624.     'skip$
  625.   if$
  626. }
  627. FUNCTION {emphasize}
  628. { duplicate$ empty$
  629.     { pop$ "" }
  630.     { "{\em " swap$ * "}" * }
  631.   if$
  632. }
  633. FUNCTION {embolden}
  634. { duplicate$ empty$
  635.     { pop$ "" }
  636.     { "{\bf " swap$ * "}" * }
  637.   if$
  638. }
  639. FUNCTION {paren}
  640. { duplicate$ empty$
  641.     { pop$ "" }
  642.     { "(" swap$ * ")" * }
  643.   if$
  644. }
  645. INTEGERS { nameptr namesleft numnames }
  646. INTEGERS { etal }
  647. FUNCTION {format.names}
  648. { 's :=
  649.   #1 'nameptr :=
  650.   s num.names$ 'numnames :=
  651.   numnames #5 >
  652.   s numnames "{ll}" format.name$ "others" = numnames #1 > and
  653.   or 'etal :=
  654.   etal
  655.     { #1 #1 + 'namesleft := }
  656.     { numnames 'namesleft := }
  657.   if$
  658.     { namesleft #0 > }
  659.     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
  660.       nameptr #1 >
  661.     { namesleft #1 >
  662.         { ", " * t * }
  663.         { nameptr #2 >
  664.         { "," * }
  665.         'skip$
  666.           if$
  667.           t "others" =
  668.           etal or
  669.         { " et~al." * }
  670.         { " and " * t * }
  671.           if$
  672.         }
  673.       if$
  674.     }
  675.     't
  676.       if$
  677.       nameptr #1 + 'nameptr :=
  678.       namesleft #1 - 'namesleft :=
  679.     }
  680.   while$
  681. }
  682. FUNCTION {format.authors}
  683. { author empty$
  684.     { "" }
  685.     { author format.names }
  686.   if$
  687. }
  688. FUNCTION {format.editors}
  689. { editor empty$
  690.     { "" }
  691.     { editor format.names
  692.       editor num.names$ #1 >
  693.     { ", editors" * }
  694.     { ", editor" * }
  695.       if$
  696.     }
  697.   if$
  698. }
  699. FUNCTION {format.edited}
  700. { editor empty$
  701.     { "" }
  702.     { "edited by " editor format.names * }
  703.   if$
  704. }
  705. % The format.title function is used for non-book-like titles.
  706. % For most styles we convert to lowercase (except for the very first letter,
  707. % and except for the first one after a colon (followed by whitespace)),
  708. % and hope the user has brace-surrounded words that need to stay capitilized;
  709. % for some styles, however, we leave it as it is in the database.
  710. FUNCTION {format.title}
  711. { title empty$
  712.     { "" }
  713.     { title "t" change.case$ }
  714.   if$
  715. }
  716. % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
  717. % constant glob_str_size, the maximum length of a global string variable.
  718. % Analogously, BibTeX sets the global integer variable entry.max$ to
  719. % ent_str_size, the maximum length of an entry string variable.
  720. % The style designer may change these if necessary (but this is unlikely)
  721. % The n.dashify function makes each single `-' in a string a double `--'
  722. % if it's not already
  723. %
  724. % pseudoVAR: pageresult: STRING        (it's what's accumulated on the stack)
  725. %
  726. % n.dashify(s) ==
  727. %  BEGIN
  728. %    t := s
  729. %    pageresult := ""
  730. %    while (not empty$(t))
  731. %      do
  732. %        if (first character of t = "-")
  733. %          then
  734. %        if (next character isn't)
  735. %          then
  736. %            pageresult := pageresult * "--"
  737. %            t := t with the "-" removed
  738. %          else
  739. %            while (first character of t = "-")
  740. %              do
  741. %            pageresult := pageresult * "-"
  742. %            t := t with the "-" removed
  743. %              od
  744. %        fi
  745. %          else
  746. %        pageresult := pageresult * the first character
  747. %        t := t with the first character removed
  748. %        fi
  749. %      od
  750. %    return pageresult
  751. %  END
  752. FUNCTION {n.dashify}
  753. { 't :=
  754.   ""
  755.     { t empty$ not }
  756.     { t #1 #1 substring$ "-" =
  757.     { t #1 #2 substring$ "--" = not
  758.         { "--" *
  759.           t #2 global.max$ substring$ 't :=
  760.         }
  761.         {   { t #1 #1 substring$ "-" = }
  762.         { "-" *
  763.           t #2 global.max$ substring$ 't :=
  764.         }
  765.           while$
  766.         }
  767.       if$
  768.     }
  769.     { t #1 #1 substring$ *
  770.       t #2 global.max$ substring$ 't :=
  771.     }
  772.       if$
  773.     }
  774.   while$
  775. }
  776. FUNCTION {first.page}
  777. { 't :=
  778.   ""
  779.     {  t empty$ not t #1 #1 substring$ "-" = not and }
  780.     { t #1 #1 substring$ *
  781.       t #2 global.max$ substring$ 't :=
  782.     }
  783.   while$
  784. }
  785. % The format.date function is for the month and year, but we give a warning if
  786. % there's an empty year but the month is there, and we return the empty string
  787. % if they're both empty.
  788. FUNCTION {format.date}
  789. { year empty$
  790.     { "" }
  791.     'year
  792.   if$
  793. }
  794. % The format.btitle is for formatting the title field when it is a book-like
  795. % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
  796. FUNCTION {format.btitle}
  797. { title emphasize
  798. }
  799. % For several functions we'll need to connect two strings with a
  800. % tie (~) if the second one isn't very long (fewer than 3 characters).
  801. % The tie.or.space.connect function does that.  It concatenates the two
  802. % strings on top of the stack, along with either a tie or space between
  803. % them, and puts this concatenation back onto the stack:
  804. %
  805. % tie.or.space.connect(str1,str2) ==
  806. %    BEGIN
  807. %    if text.length$(str2) < 3
  808. %      then return the concatenation of str1, "~", and str2
  809. %      else return the concatenation of str1, " ", and str2
  810. %    END
  811. FUNCTION {tie.or.space.connect}
  812. { duplicate$ text.length$ #3 <
  813.     { "~" }
  814.     { " " }
  815.   if$
  816.   swap$ * *
  817. }
  818. % The either.or.check function complains if both fields or an either-or pair
  819. % are nonempty.
  820. %
  821. % either.or.check(t,s) ==
  822. %  BEGIN
  823. %    if empty$(s) then
  824. %        warning$(can't use both " * t * " fields in " * cite$)
  825. %    fi
  826. %  END
  827. FUNCTION {either.or.check}
  828. { empty$
  829.     'pop$
  830.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  831.   if$
  832. }
  833. % The format.bvolume function is for formatting the volume and perhaps
  834. % series name of a multivolume work.  If both a volume and a series field
  835. % are there, we assume the series field is the title of the whole multivolume
  836. % work (the title field should be the title of the thing being referred to),
  837. % and we add an "of <series>".  This function is called in mid-sentence.
  838. FUNCTION {format.bvolume}
  839. { volume empty$
  840.     { "" }
  841.     { "volume" volume tie.or.space.connect
  842.       series empty$
  843.     'skip$
  844.     { " of " * series emphasize * }
  845.       if$
  846.       "volume and number" number either.or.check
  847.     }
  848.   if$
  849. }
  850. % The format.number.series function is for formatting the series name
  851. % and perhaps number of a work in a series.  This function is similar to
  852. % format.bvolume, although for this one the series must exist (and the
  853. % volume must not exist).  If the number field is empty we output either
  854. % the series field unchanged if it exists or else the null string.
  855. % If both the number and series fields are there we assume the series field
  856. % gives the name of the whole series (the title field should be the title
  857. % of the work being one referred to), and we add an "in <series>".
  858. % We capitilize Number when this function is used at the beginning of a block.
  859. FUNCTION {format.number.series}
  860. { volume empty$
  861.     { number empty$
  862.     { series field.or.null }
  863.     { output.state mid.sentence =
  864.         { "number" }
  865.         { "Number" }
  866.       if$
  867.       number tie.or.space.connect
  868.       series empty$
  869.         { "there's a number but no series in " cite$ * warning$ }
  870.         { " in " * series * }
  871.       if$
  872.     }
  873.       if$
  874.     }
  875.     { "" }
  876.   if$
  877. }
  878. % The format.edition function appends " edition" to the edition, if present.
  879. % We lowercase the edition (it should be something like "Third"), because
  880. % this doesn't start a sentence.
  881. FUNCTION {format.edition}
  882. { edition empty$
  883.     { "" }
  884.     { output.state mid.sentence =
  885.     { edition "l" change.case$ " edition" * }
  886.     { edition "t" change.case$ " edition" * }
  887.       if$
  888.     }
  889.   if$
  890. }
  891. % The format.pages function is used for formatting a page range in a book
  892. % (and in rare circumstances, an article).
  893. %
  894. % The multi.page.check function examines the page field for a "-" or "," or "+"
  895. % so that format.pages can use "page" instead of "pages" if none exists.
  896. % Note: global.max$ here means "take the rest of the string"
  897. %
  898. % VAR: multiresult: INTEGER    (actually, a boolean)
  899. %
  900. % multi.page.check(s) ==
  901. %  BEGIN
  902. %    t := s
  903. %    multiresult := false
  904. %    while ((not multiresult) and (not empty$(t)))
  905. %      do
  906. %        if (first character of t = "-" or "," or "+")
  907. %          then multiresult := true
  908. %          else t := t with the first character removed
  909. %        fi
  910. %      od
  911. %    return multiresult
  912. %  END
  913. INTEGERS { multiresult }
  914. FUNCTION {multi.page.check}
  915. { 't :=
  916.   #0 'multiresult :=
  917.     { multiresult not
  918.       t empty$ not
  919.       and
  920.     }
  921.     { t #1 #1 substring$
  922.       duplicate$ "-" =
  923.       swap$ duplicate$ "," =
  924.       swap$ "+" =
  925.       or or
  926.     { #1 'multiresult := }
  927.     { t #2 global.max$ substring$ 't := }
  928.       if$
  929.     }
  930.   while$
  931.   multiresult
  932. }
  933. % This function doesn't begin a sentence so "pages" isn't capitalized.
  934. % Other functions that use this should keep that in mind.
  935. FUNCTION {format.pages}
  936. { pages empty$
  937.     { "" }
  938.     { pages multi.page.check
  939.     { "pages" pages n.dashify tie.or.space.connect }
  940.     { "page" pages tie.or.space.connect }
  941.       if$
  942.     }
  943.   if$
  944. }
  945. FUNCTION {format.pages.a}
  946. { pages empty$
  947.     { "" }
  948.     { "page" pages first.page tie.or.space.connect }
  949.   if$
  950. }
  951. % The format.vol.num.pages function is for the volume, number, and page range
  952. % of a journal article.  We use the format:  vol(number):pages, with some
  953. % variations for empty fields.  This doesn't begin a sentence.
  954. FUNCTION {format.vol.num.pages}
  955. { volume field.or.null embolden
  956.   " " swap$ * *
  957.   pages empty$
  958.     'skip$
  959.     { duplicate$ empty$
  960.     { pop$ format.pages.a }
  961.     { ", " * pages first.page * }
  962.       if$
  963.     }
  964.   if$
  965. }
  966. % The format.chapter.pages, if the chapter is present, puts whatever is in the
  967. % type field (or else "chapter" if type is empty) in front of a chapter number.
  968. % It then appends the pages, if present.  This doesn't begin a sentence.
  969. FUNCTION {format.chapter.pages}
  970. { chapter empty$
  971.     'format.pages
  972.     { type empty$
  973.     { "chapter" }
  974.     { type "l" change.case$ }
  975.       if$
  976.       chapter tie.or.space.connect
  977.       pages empty$
  978.     'skip$
  979.     { ", " * format.pages * }
  980.       if$
  981.     }
  982.   if$
  983. }
  984. % The format.in.ed.booktitle function is used for starting out a sentence
  985. % that begins "In <booktitle>", putting an editor before the title if one
  986. % exists.
  987. FUNCTION {format.in.ed.booktitle}
  988. { booktitle empty$
  989.     { "" }
  990.     { editor empty$
  991.     { "in " booktitle emphasize * }
  992.     { "in " booktitle emphasize * ", " * format.edited * }
  993.       if$
  994.     }
  995.   if$
  996. }
  997. % The function empty.misc.check complains if all six fields are empty, and
  998. % if there's been no sorting or alphabetic-label complaint.
  999. FUNCTION {empty.misc.check}
  1000. { author empty$ title empty$ howpublished empty$
  1001.   month empty$ year empty$ note empty$
  1002.   and and and and and
  1003.     { "all relevant fields are empty in " cite$ * warning$ }
  1004.     'skip$
  1005.   if$
  1006. }
  1007. % The function format.thesis.type returns either the (case-changed) type field,
  1008. % if it is defined, or else the default string already on the stack
  1009. % (like "Master's thesis" or "PhD thesis").
  1010. FUNCTION {format.thesis.type}
  1011. { type empty$
  1012.     'skip$
  1013.     { pop$
  1014.       type "t" change.case$
  1015.     }
  1016.   if$
  1017. }
  1018. % The function format.tr.number makes a string starting with "Technical Report"
  1019. % (or type, if that field is defined), followed by the number if there is one;
  1020. % it returns the starting part (with a case change) even if there is no number.
  1021. % This is used at the beginning of a sentence.
  1022. FUNCTION {format.tr.number}
  1023. { type empty$
  1024.     { "Technical Report" }
  1025.     'type
  1026.   if$
  1027.   number empty$
  1028.     { "t" change.case$ }
  1029.     { number tie.or.space.connect }
  1030.   if$
  1031. }
  1032. % Now come the cross-referencing functions (these are invoked because
  1033. % one entry in the database file(s) cross-references another, by giving
  1034. % the other entry's database key in a `crossref' field).  This feature
  1035. % allows one or more titled things that are part of a larger titled
  1036. % thing to cross-reference the larger thing.  These styles allow for
  1037. % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
  1038. % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
  1039. % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
  1040. % Each of these is explained in more detail later.
  1041. %
  1042. % An ARTICLE entry type may cross reference another ARTICLE (this is
  1043. % intended for when an entire journal is devoted to a single topic---
  1044. % but since there is no JOURNAL entry type, the journal, too, should be
  1045. % classified as an ARTICLE but without the author and title fields).
  1046. % This will result in two warning messages for the journal's entry
  1047. % if it's included in the reference list, but such is life.
  1048. %
  1049. % format.article.crossref ==
  1050. %  BEGIN
  1051. %    if empty$(key) then
  1052. %        if empty$(journal) then
  1053. %        warning$("need key or journal for " * cite$ *
  1054. %                        " to crossref " * crossref)
  1055. %        return(" \cite{" * crossref * "}")
  1056. %        else
  1057. %        return("In " * emphazise.correct (journal) *
  1058. %                        " \cite{" * crossref * "}")
  1059. %        fi
  1060. %    else
  1061. %        return("In " * key * " \cite{" * crossref * "}")
  1062. %    fi
  1063. %  END
  1064. %
  1065. % The other cross-referencing functions are similar, so no "comment version"
  1066. % will be given for them.
  1067. FUNCTION {format.article.crossref}
  1068. { key empty$
  1069.     { journal empty$
  1070.     { "need key or journal for " cite$ * " to crossref " * crossref *
  1071.       warning$
  1072.       ""
  1073.     }
  1074.     { "In " journal * }
  1075.       if$
  1076.     }
  1077.     { "In " key * }
  1078.   if$
  1079.   " \cite{" * crossref * "}" *
  1080. }
  1081. % We use just the last names of editors for a cross reference: either
  1082. % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
  1083. % whether there are one, or two, or more than two editors.
  1084. FUNCTION {format.crossref.editor}
  1085. { editor #1 "{vv~}{ll}" format.name$
  1086.   editor num.names$ duplicate$
  1087.   #2 >
  1088.     { pop$ " et~al." * }
  1089.     { #2 <
  1090.     'skip$
  1091.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1092.         { " et~al." * }
  1093.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  1094.       if$
  1095.     }
  1096.       if$
  1097.     }
  1098.   if$
  1099. }
  1100. % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
  1101. % multivolume work) may cross reference another BOOK (the entire multivolume).
  1102. % Usually there will be an editor, in which case we use that to construct the
  1103. % cross reference; otherwise we use a nonempty key field or else the series
  1104. % field (since the series gives the title of the multivolume work).
  1105. FUNCTION {format.book.crossref}
  1106. { volume empty$
  1107.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  1108.       "In "
  1109.     }
  1110.     { "Volume" volume tie.or.space.connect
  1111.       " of " *
  1112.     }
  1113.   if$
  1114.   editor empty$
  1115.   editor field.or.null author field.or.null =
  1116.   or
  1117.     { key empty$
  1118.     { series empty$
  1119.         { "need editor, key, or series for " cite$ * " to crossref " *
  1120.           crossref * warning$
  1121.           "" *
  1122.         }
  1123.         { "{\em " * series * "\/}" * }
  1124.       if$
  1125.     }
  1126.     { key * }
  1127.       if$
  1128.     }
  1129.     { format.crossref.editor * }
  1130.   if$
  1131.   " \cite{" * crossref * "}" *
  1132. }
  1133. % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
  1134. % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
  1135. % Often there will be an editor, in which case we use that to construct
  1136. % the cross reference; otherwise we use a nonempty key field or else
  1137. % the booktitle field (which gives the cross-referenced work's title).
  1138. FUNCTION {format.incoll.inproc.crossref}
  1139. { editor empty$
  1140.   editor field.or.null author field.or.null =
  1141.   or
  1142.     { key empty$
  1143.     { booktitle empty$
  1144.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  1145.           crossref * warning$
  1146.           ""
  1147.         }
  1148.         { "In {\em " booktitle * "\/}" * }
  1149.       if$
  1150.     }
  1151.     { "In " key * }
  1152.       if$
  1153.     }
  1154.     { "In " format.crossref.editor * }
  1155.   if$
  1156.   " \cite{" * crossref * "}" *
  1157. }
  1158. % Now we define the type functions for all entry types that may appear
  1159. % in the .BIB file---e.g., functions like `article' and `book'.  These
  1160. % are the routines that actually generate the .BBL-file output for
  1161. % the entry.  These must all precede the READ command.  In addition, the
  1162. % style designer should have a function `default.type' for unknown types.
  1163. % Note: The fields (within each list) are listed in order of appearance,
  1164. % except as described for an `inbook' or a `proceedings'.
  1165. %
  1166. % The article function is for an article in a journal.  An article may
  1167. % CROSSREF another article.
  1168. %    Required fields: author, title, journal, year
  1169. %    Optional fields: volume, number, pages, month, note
  1170. %
  1171. % article ==
  1172. %  BEGIN
  1173. %    output.bibitem
  1174. %    output.check(format.authors,"author")
  1175. %    new.block
  1176. %    output.check(format.title,"title")
  1177. %    new.block
  1178. %    if missing$(crossref) then
  1179. %        output.check(emphasize(journal),"journal")
  1180. %        output(format.vol.num.pages)
  1181. %        output.check(format.date,"year")
  1182. %       else
  1183. %        output.nonnull(format.article.crossref)
  1184. %        output(format.pages)
  1185. %    fi
  1186. %    new.block
  1187. %    output(note)
  1188. %    fin.entry
  1189. %  END
  1190. %
  1191. % The book function is for a whole book.  A book may CROSSREF another book.
  1192. %    Required fields: author or editor, title, publisher, year
  1193. %    Optional fields: volume or number, series, address, edition, month,
  1194. %            note
  1195. %
  1196. % book ==
  1197. %  BEGIN
  1198. %    if empty$(author) then output.check(format.editors,"author and editor")
  1199. %    else    output.check(format.authors,"author")
  1200. %        if missing$(crossref) then
  1201. %            either.or.check("author and editor",editor)
  1202. %        fi
  1203. %    fi
  1204. %    new.block
  1205. %    output.check(format.btitle,"title")
  1206. %    if missing$(crossref) then
  1207. %        output(format.bvolume)
  1208. %        new.block
  1209. %        output(format.number.series)
  1210. %        new.sentence
  1211. %        output.check(publisher,"publisher")
  1212. %        output(address)
  1213. %       else
  1214. %        new.block
  1215. %        output.nonnull(format.book.crossref)
  1216. %    fi
  1217. %    output(format.edition)
  1218. %    output.check(format.date,"year")
  1219. %    new.block
  1220. %    output(note)
  1221. %    fin.entry
  1222. %  END
  1223. %
  1224. % The other entry functions are all quite similar, so no "comment version"
  1225. % will be given for them.
  1226. FUNCTION {article}
  1227. { output.bibitem
  1228.   format.authors "author" output.check
  1229.   new.block
  1230.   crossref missing$
  1231.     { journal field.or.null
  1232.       format.vol.num.pages 
  1233.       format.date empty$
  1234.     'skip$
  1235.     { duplicate$ empty$
  1236.         { pop$ format.date paren }
  1237.             { " " * format.date paren * }
  1238.       if$
  1239.     }
  1240.       if$
  1241.       output
  1242.     }
  1243.     { format.article.crossref output.nonnull
  1244.       format.pages output
  1245.     }
  1246.   if$
  1247.   new.block
  1248.   note output
  1249.   fin.entry
  1250. }
  1251. FUNCTION {book}
  1252. { output.bibitem
  1253.   author empty$
  1254.     { format.editors "author and editor" output.check }
  1255.     { format.authors output.nonnull
  1256.       crossref missing$
  1257.     { "author and editor" editor either.or.check }
  1258.     'skip$
  1259.       if$
  1260.     }
  1261.   if$
  1262.   new.block
  1263.   format.btitle "title" output.check
  1264.   crossref missing$
  1265.     { format.bvolume output
  1266.       new.block
  1267.       format.number.series output
  1268.       new.sentence
  1269.       publisher "publisher" output.check
  1270.       address output
  1271.     }
  1272.     { new.block
  1273.       format.book.crossref output.nonnull
  1274.     }
  1275.   if$
  1276.   format.edition output
  1277.   format.date "year" output.check
  1278.   new.block
  1279.   note output
  1280.   fin.entry
  1281. }
  1282. % A booklet is a bound thing without a publisher or sponsoring institution.
  1283. %    Required: title
  1284. %    Optional: author, howpublished, address, month, year, note
  1285. FUNCTION {booklet}
  1286. { output.bibitem
  1287.   format.authors output
  1288.   new.block
  1289.   format.title "title" output.check
  1290.   howpublished address new.block.checkb
  1291.   howpublished output
  1292.   address output
  1293.   format.date output
  1294.   new.block
  1295.   note output
  1296.   fin.entry
  1297. }
  1298. % For the conference entry type, see inproceedings.
  1299. % An inbook is a piece of a book: either a chapter and/or a page range.
  1300. % It may CROSSREF a book.  If there's no volume field, the type field
  1301. % will come before number and series.
  1302. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1303. %    Optional: volume or number, series, type, address, edition, month, note
  1304. FUNCTION {inbook}
  1305. { output.bibitem
  1306.   author empty$
  1307.     { format.editors "author and editor" output.check }
  1308.     { format.authors output.nonnull
  1309.       crossref missing$
  1310.     { "author and editor" editor either.or.check }
  1311.     'skip$
  1312.       if$
  1313.     }
  1314.   if$
  1315.   new.block
  1316.   format.btitle "title" output.check
  1317.   crossref missing$
  1318.     { format.bvolume output
  1319.       format.chapter.pages "chapter and pages" output.check
  1320.       new.block
  1321.       format.number.series output
  1322.       new.sentence
  1323.       publisher "publisher" output.check
  1324.       address output
  1325.     }
  1326.     { format.chapter.pages "chapter and pages" output.check
  1327.       new.block
  1328.       format.book.crossref output.nonnull
  1329.     }
  1330.   if$
  1331.   format.edition output
  1332.   format.date "year" output.check
  1333.   new.block
  1334.   note output
  1335.   fin.entry
  1336. }
  1337. % An incollection is like inbook, but where there is a separate title
  1338. % for the referenced thing (and perhaps an editor for the whole).
  1339. % An incollection may CROSSREF a book.
  1340. %    Required: author, title, booktitle, publisher, year
  1341. %    Optional: editor, volume or number, series, type, chapter, pages,
  1342. %            address, edition, month, note
  1343. FUNCTION {incollection}
  1344. { output.bibitem
  1345.   format.authors "author" output.check
  1346.   new.block
  1347.   format.title "title" output.check
  1348.   new.block
  1349.   crossref missing$
  1350.     { format.in.ed.booktitle "booktitle" output.check
  1351.       format.bvolume output
  1352.       format.number.series output
  1353.       format.chapter.pages output
  1354.       new.sentence
  1355.       publisher "publisher" output.check
  1356.       address output
  1357.       format.edition output
  1358.       format.date "year" output.check
  1359.     }
  1360.     { format.incoll.inproc.crossref output.nonnull
  1361.       format.chapter.pages output
  1362.     }
  1363.   if$
  1364.   new.block
  1365.   note output
  1366.   fin.entry
  1367. }
  1368. % An inproceedings is an article in a conference proceedings, and it may
  1369. % CROSSREF a proceedings.  If there's no address field, the month (& year)
  1370. % will appear just before note.
  1371. %    Required: author, title, booktitle, year
  1372. %    Optional: editor, volume or number, series, pages, address, month,
  1373. %            organization, publisher, note
  1374. FUNCTION {inproceedings}
  1375. { output.bibitem
  1376.   format.authors "author" output.check
  1377.   new.block
  1378.   format.title "title" output.check
  1379.   new.block
  1380.   crossref missing$
  1381.     { format.in.ed.booktitle "booktitle" output.check
  1382.       format.bvolume output
  1383.       format.number.series output
  1384.       format.pages output
  1385.       address empty$
  1386.     { organization publisher new.sentence.checkb
  1387.       organization output
  1388.       publisher output
  1389.       format.date "year" output.check
  1390.     }
  1391.     { address output.nonnull
  1392.       format.date "year" output.check
  1393.       new.sentence
  1394.       organization output
  1395.       publisher output
  1396.     }
  1397.       if$
  1398.     }
  1399.     { format.incoll.inproc.crossref output.nonnull
  1400.       format.pages output
  1401.     }
  1402.   if$
  1403.   new.block
  1404.   note output
  1405.   fin.entry
  1406. }
  1407. % The conference function is included for Scribe compatibility.
  1408. FUNCTION {conference} { inproceedings }
  1409. % A manual is technical documentation.
  1410. %    Required: title
  1411. %    Optional: author, organization, address, edition, month, year, note
  1412. FUNCTION {manual}
  1413. { output.bibitem
  1414.   author empty$
  1415.     { organization empty$
  1416.     'skip$
  1417.     { organization output.nonnull
  1418.       address output
  1419.     }
  1420.       if$
  1421.     }
  1422.     { format.authors output.nonnull }
  1423.   if$
  1424.   new.block
  1425.   format.btitle "title" output.check
  1426.   author empty$
  1427.     { organization empty$
  1428.     { address new.block.checka
  1429.       address output
  1430.     }
  1431.     'skip$
  1432.       if$
  1433.     }
  1434.     { organization address new.block.checkb
  1435.       organization output
  1436.       address output
  1437.     }
  1438.   if$
  1439.   format.edition output
  1440.   format.date output
  1441.   new.block
  1442.   note output
  1443.   fin.entry
  1444. }
  1445. % A mastersthesis is a Master's thesis.
  1446. %    Required: author, title, school, year
  1447. %    Optional: type, address, month, note
  1448. FUNCTION {mastersthesis}
  1449. { output.bibitem
  1450.   format.authors "author" output.check
  1451.   new.block
  1452.   format.title "title" output.check
  1453.   new.block
  1454.   "Master's thesis" format.thesis.type output.nonnull
  1455.   school "school" output.check
  1456.   address output
  1457.   format.date "year" output.check
  1458.   new.block
  1459.   note output
  1460.   fin.entry
  1461. }
  1462. % A misc is something that doesn't fit elsewhere.
  1463. %    Required: at least one of the `optional' fields
  1464. %    Optional: author, title, howpublished, month, year, note
  1465. FUNCTION {misc}
  1466. { output.bibitem
  1467.   format.authors output
  1468.   title howpublished new.block.checkb
  1469.   format.title output
  1470.   howpublished new.block.checka
  1471.   howpublished output
  1472.   format.date output
  1473.   new.block
  1474.   note output
  1475.   fin.entry
  1476.   empty.misc.check
  1477. }
  1478. % A phdthesis is like a mastersthesis.
  1479. %    Required: author, title, school, year
  1480. %    Optional: type, address, month, note
  1481. FUNCTION {phdthesis}
  1482. { output.bibitem
  1483.   format.authors "author" output.check
  1484.   new.block
  1485.   format.btitle "title" output.check
  1486.   new.block
  1487.   "PhD thesis" format.thesis.type output.nonnull
  1488.   school "school" output.check
  1489.   address output
  1490.   format.date "year" output.check
  1491.   new.block
  1492.   note output
  1493.   fin.entry
  1494. }
  1495. % A proceedings is a conference proceedings.
  1496. % If there is an organization but no editor field, the organization will
  1497. % appear as the first optional field (we try to make the first block nonempty);
  1498. % if there's no address field, the month (& year) will appear just before note.
  1499. %    Required: title, year
  1500. %    Optional: editor, volume or number, series, address, month,
  1501. %            organization, publisher, note
  1502. FUNCTION {proceedings}
  1503. { output.bibitem
  1504.   editor empty$
  1505.     { organization output }
  1506.     { format.editors output.nonnull }
  1507.   if$
  1508.   new.block
  1509.   format.btitle "title" output.check
  1510.   format.bvolume output
  1511.   format.number.series output
  1512.   address empty$
  1513.     { editor empty$
  1514.     { publisher new.sentence.checka }
  1515.     { organization publisher new.sentence.checkb
  1516.       organization output
  1517.     }
  1518.       if$
  1519.       publisher output
  1520.       format.date "year" output.check
  1521.     }
  1522.     { address output.nonnull
  1523.       format.date "year" output.check
  1524.       new.sentence
  1525.       editor empty$
  1526.     'skip$
  1527.     { organization output }
  1528.       if$
  1529.       publisher output
  1530.     }
  1531.   if$
  1532.   new.block
  1533.   note output
  1534.   fin.entry
  1535. }
  1536. % A techreport is a technical report.
  1537. %    Required: author, title, institution, year
  1538. %    Optional: type, number, address, month, note
  1539. FUNCTION {techreport}
  1540. { output.bibitem
  1541.   format.authors "author" output.check
  1542.   new.block
  1543.   format.title "title" output.check
  1544.   new.block
  1545.   format.tr.number output.nonnull
  1546.   institution "institution" output.check
  1547.   address output
  1548.   format.date "year" output.check
  1549.   new.block
  1550.   note output
  1551.   fin.entry
  1552. }
  1553. % An unpublished is something that hasn't been published.
  1554. %    Required: author, title, note
  1555. %    Optional: month, year
  1556. FUNCTION {unpublished}
  1557. { output.bibitem
  1558.   format.authors "author" output.check
  1559.   new.block
  1560.   format.title "title" output.check
  1561.   new.block
  1562.   note "note" output.check
  1563.   format.date output
  1564.   fin.entry
  1565. }
  1566. % We use entry type `misc' for an unknown type; BibTeX gives a warning.
  1567. FUNCTION {default.type} { misc }
  1568. % Here are macros for common things that may vary from style to style.
  1569. % Users are encouraged to use these macros.
  1570. %
  1571. % Months are either written out in full or abbreviated
  1572. MACRO {jan} {"Jan."}
  1573. MACRO {feb} {"Feb."}
  1574. MACRO {mar} {"Mar."}
  1575. MACRO {apr} {"Apr."}
  1576. MACRO {may} {"May"}
  1577. MACRO {jun} {"June"}
  1578. MACRO {jul} {"July"}
  1579. MACRO {aug} {"Aug."}
  1580. MACRO {sep} {"Sept."}
  1581. MACRO {oct} {"Oct."}
  1582. MACRO {nov} {"Nov."}
  1583. MACRO {dec} {"Dec."}
  1584. % Journals are either written out in full or abbreviated;
  1585. % the abbreviations are like those found in ACM publications.
  1586. %
  1587. % To get a completely different set of abbreviations, it may be best to make
  1588. % a separate .bib file with nothing but those abbreviations; users could then
  1589. % include that file name as the first argument to the \bibliography command
  1590. MACRO {acmcs} {"ACM Comput. Surv."}
  1591. MACRO {acta} {"Acta Inf."}
  1592. MACRO {cacm} {"Commun. ACM"}
  1593. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1594. MACRO {ibmsj} {"IBM Syst.~J."}
  1595. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1596. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1597. MACRO {ieeetcad}
  1598.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1599. MACRO {ipl} {"Inf. Process. Lett."}
  1600. MACRO {jacm} {"J.~ACM"}
  1601. MACRO {jcss} {"J.~Comput. Syst. Sci."}
  1602. MACRO {scp} {"Sci. Comput. Programming"}
  1603. MACRO {sicomp} {"SIAM J. Comput."}
  1604. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1605. MACRO {tods} {"ACM Trans. Database Syst."}
  1606. MACRO {tog} {"ACM Trans. Gr."}
  1607. MACRO {toms} {"ACM Trans. Math. Softw."}
  1608. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1609. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1610. MACRO {tcs} {"Theoretical Comput. Sci."}
  1611. %% /usr/local/lib/tex/bibtex/phyjfull.btx, Tue Jun 30 08:37:48 1992
  1612. %% Edit by Nelson H. F. Beebe <beebe@alfred.math.utah.edu>
  1613. %% Change file names in leading comment
  1614. % Journal Title Abbreviations from the Physical Review Style and Notation
  1615. %    Guide, July, 1983, in BAPS Vol. 28.
  1616. %  Selected by Cris Barnes and Charles Karney, March 1988
  1617. % IMPORTANT!! Don't make changes to this file without making the
  1618. %           corresponding changes to
  1619. %            phyjabb.bib
  1620. %            phyjabb.btx
  1621. MACRO {advp} {"Advances in Physics"}
  1622. MACRO {ajp} {"American Journal of Physics"}
  1623. MACRO {ao} {"Applied Optics"}
  1624. MACRO {apl} {"Applied Physics Letters"}
  1625. MACRO {apj} {"Astrophysical Journal"}
  1626. MACRO {baps} {"Bulletin of the American Physical Society"}
  1627. MACRO {cpc} {"Computer Physics Communications"}
  1628. MACRO {cppcf} {"Comments on Plasma Physics and Controlled Fusion"}
  1629. MACRO {fed} {"Fusion Engineering and Design"}
  1630. MACRO {ft} {"Fusion Technology"}
  1631. MACRO {ieeens} {"IEEE Transactions on Nuclear Science"}
  1632. MACRO {ieeeps} {"IEEE Transactions on Plasma Science"}
  1633. MACRO {ijimw} {"International Journal of Infrared and Millimeter Waves"}
  1634. MACRO {ip} {"Infrared Physics"}
  1635. MACRO {jap} {"Journal of Applied Physics"}
  1636. MACRO {jcp} {"Journal of Computational Physics"}
  1637. MACRO {jetp} {"Soviet Physics-JETP"}
  1638. MACRO {jfe} {"Journal of Fusion Energy"}
  1639. MACRO {jfm} {"Journal of Fluid Mechanics"}
  1640. MACRO {jgr} {"Journal of Geophysical Research"}
  1641. MACRO {jmp} {"Journal of Mathematical Physics"}
  1642. MACRO {jne} {"Journal of Nuclear Energy"}
  1643. MACRO {jnec} {"Journal of Nuclear Energy, Part C: Plasma Physics, Accelerators, Thermonuclear Research"}
  1644. MACRO {jnm} {"Journal of Nuclear Materials"}
  1645. MACRO {josa} {"Journal of the Optical Society of America"}
  1646. MACRO {jpp} {"Journal of Plasma Physics"}
  1647. MACRO {jpsj} {"Journal of the Physical Society of Japan"}
  1648. MACRO {jvst} {"Journal of Vacuum Science and Technology"}
  1649. MACRO {nedf} {"Nuclear Engineering and Design/Fusion"}
  1650. MACRO {nf} {"Nuclear Fusion"}
  1651. MACRO {nim} {"Nuclear Instruments and Methods"}
  1652. MACRO {nimpr} {"Nuclear Instruments and Methods in Physics Research"}
  1653. MACRO {nt/f} {"Nuclear Technology/Fusion"}
  1654. MACRO {pf} {"Physics of Fluids"}
  1655. MACRO {pfa} {"Physics of Fluids A: Fluid Dynamics"}
  1656. MACRO {pfb} {"Physics of Fluids B: Plasma Physics"}
  1657. MACRO {pl} {"Physics Letters"}
  1658. MACRO {pla} {"Physics Letters A"}
  1659. MACRO {pnas} {"Proceedings of the National Academy of Sciences of the USA"}
  1660. MACRO {pp} {"Plasma Physics"}
  1661. MACRO {ppcf} {"Plasma Physics and Controlled Fusion"}
  1662. MACRO {prl} {"Physical Review Letters"}
  1663. MACRO {pr} {"Physical Review"}
  1664. MACRO {pra} {"Physical Review A: General Physics"}
  1665. MACRO {ps} {"Physica Scripta"}
  1666. MACRO {rmp} {"Reviews of Modern Physics"}
  1667. MACRO {rsi} {"Review of Scientific Instruments"}
  1668. MACRO {sjpp} {"Soviet Journal of Plasma Phys."}
  1669. MACRO {spd} {"Soviet Physics-Doklady"}
  1670. MACRO {sptp} {"Soviet Physics-Technical Physics"}
  1671. MACRO {spu} {"Soviet Physics-Uspeki"}
  1672. % Now we read in the .BIB entries.
  1673. READ
  1674. % The sortify function converts to lower case after purify$ing; it's
  1675. % used in sorting and in computing alphabetic labels after sorting
  1676. %
  1677. % The chop.word(w,len,s) function returns either s or, if the first len
  1678. % letters of s equals w (this comparison is done in the third line of the
  1679. % function's definition), it returns that part of s after w.
  1680. % This long comment applies only to alphabetic labels
  1681. %
  1682. % The format.lab.names function makes a short label by using the initials of
  1683. % the von and Last parts of the names (but if there are more than four names,
  1684. % (i.e., people) it truncates after three and adds a superscripted "+";
  1685. % it also adds such a "+" if the last of multiple authors is "others").
  1686. % If there is only one name, and its von and Last parts combined have just
  1687. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1688. % we take the first three letters of the last name.  The boolean
  1689. % et.al.char.used tells whether we've used a superscripted "+", so that we
  1690. % know whether to include a LaTeX macro for it.
  1691. %
  1692. % format.lab.names(s) ==
  1693. %  BEGIN
  1694. %    numnames := num.names$(s)
  1695. %    if numnames > 1 then
  1696. %        if numnames > 4 then
  1697. %        namesleft := 3
  1698. %        else
  1699. %        namesleft := numnames
  1700. %        nameptr := 1
  1701. %        nameresult := ""
  1702. %        while namesleft > 0
  1703. %          do
  1704. %        if (name_ptr = numnames) and
  1705. %             format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
  1706. %           then nameresult := nameresult * "{\etalchar{+}}"
  1707. %            et.al.char.used := true
  1708. %           else nameresult := nameresult *
  1709. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1710. %        nameptr := nameptr + 1
  1711. %        namesleft := namesleft - 1
  1712. %          od
  1713. %        if numnames > 4 then
  1714. %        nameresult := nameresult * "{\etalchar{+}}"
  1715. %        et.al.char.used := true
  1716. %    else
  1717. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1718. %        if text.length$(t) < 2 then    % there's just one name-token
  1719. %        nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
  1720. %        else
  1721. %        nameresult := t
  1722. %        fi
  1723. %    fi
  1724. %    return nameresult
  1725. %  END
  1726. %
  1727. % Exactly what fields we look at in constructing the primary part of the label
  1728. % depends on the entry type; this selectivity (as opposed to, say, always
  1729. % looking at author, then editor, then key) helps ensure that "ignored" fields,
  1730. % as described in the LaTeX book, really are ignored.  Note that MISC is part
  1731. % of the deepest `else' clause in the nested part of calc.label; thus, any
  1732. % unrecognized entry type in the database is handled correctly.
  1733. %
  1734. % There is one auxiliary function for each of the four different sequences of
  1735. % fields we use.  The first of these functions looks at the author field, and
  1736. % then, if necessary, the key field.  The other three functions, which might
  1737. % look at two fields and the key field, are similar, except that the key field
  1738. % takes precedence over the organization field (for labels---not for sorting).
  1739. %
  1740. % The calc.label function calculates the preliminary label of an entry, which
  1741. % is formed by taking three letters of information from the author or editor or
  1742. % key or organization field (depending on the entry type and on what's empty,
  1743. % but ignoring a leading "The " in the organization), and appending the last
  1744. % two characters (digits) of the year. It is an error if the appropriate fields
  1745. % among author, editor, organization, and key are missing, and we use
  1746. % the first three letters of the cite$ in desperation when this happens.
  1747. % The resulting label has the year part, but not the name part, purify$ed
  1748. % (purify$ing the year allows some sorting shenanigans by the user).
  1749. %
  1750. % This function also calculates the version of the label to be used in sorting.
  1751. %
  1752. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1753. % otherwise identical labels, but we can't calculated those "extra.label"s
  1754. % until after sorting.
  1755. %
  1756. % calc.label ==
  1757. %  BEGIN
  1758. %    if type$ = "book" or "inbook" then
  1759. %        author.editor.key.label
  1760. %    else if type$ = "proceedings" then
  1761. %        editor.key.organization.label
  1762. %    else if type$ = "manual" then
  1763. %        author.key.organization.label
  1764. %    else
  1765. %        author.key.label
  1766. %    fi fi fi
  1767. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1768. %        % assuming we will also sort, we calculate a sort.label
  1769. %    sort.label := sortify(label), but use the last four, not two, digits
  1770. %  END
  1771. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1772. % The presort key contains a number of "sortify"ed strings, concatenated
  1773. % with multiple blanks between them.  This makes things like "brinch  per"
  1774. % come before "brinch hansen  per".
  1775. %
  1776. % The fields used here are: the sort.label for alphabetic labels (as set by
  1777. % calc.label), followed by the author names (or editor names or organization
  1778. % (with a leading "The " removed) or key field, depending on entry type and on
  1779. % what's empty), followed by year, followed by the first bit of the title
  1780. % (chopping off a leading "The ", "A ", or "An ").
  1781. % Names are formatted: Von Last First Junior.
  1782. % The names within a part will be separated by a single blank
  1783. % (such as "brinch hansen"), two will separate the name parts themselves
  1784. % (except the von and last), three will separate the names,
  1785. % four will separate the names from year (and from label, if alphabetic),
  1786. % and four will separate year from title.
  1787. %
  1788. % The sort.format.names function takes an argument that should be in
  1789. % BibTeX name format, and returns a string containing "   "-separated
  1790. % names in the format described above.  The function is almost the same
  1791. % as format.names.
  1792. % This long comment applies only to alphabetic labels, when sorted
  1793. %
  1794. % Now comes the final computation for alphabetic labels, putting in the 'a's
  1795. % and 'b's and so forth if required.  This involves two passes: a forward
  1796. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  1797. % to put in the 'a's (we don't want to put in 'a's unless we know there
  1798. % are 'b's).
  1799. % We have to keep track of the longest (in width$ terms) label, for use
  1800. % by the "thebibliography" environment.
  1801. %
  1802. % VAR: longest.label, last.sort.label, next.extra: string
  1803. %      longest.label.width, last.extra.num: integer
  1804. %
  1805. % initialize.longest.label ==
  1806. %  BEGIN
  1807. %    longest.label := ""
  1808. %    last.sort.label := int.to.chr$(0)
  1809. %    next.extra := ""
  1810. %    longest.label.width := 0
  1811. %    last.extra.num := 0
  1812. %  END
  1813. %
  1814. % forward.pass ==
  1815. %  BEGIN
  1816. %    if last.sort.label = sort.label then
  1817. %        last.extra.num := last.extra.num + 1
  1818. %        extra.label := int.to.chr$(last.extra.num)
  1819. %    else
  1820. %        last.extra.num := chr.to.int$("a")
  1821. %        extra.label := ""
  1822. %        last.sort.label := sort.label
  1823. %    fi
  1824. %  END
  1825. %
  1826. % reverse.pass ==
  1827. %  BEGIN
  1828. %    if next.extra = "b" then
  1829. %        extra.label := "a"
  1830. %    fi
  1831. %    label := label * extra.label
  1832. %    if width$(label) > longest.label.width then
  1833. %        longest.label := label
  1834. %        longest.label.width := width$(label)
  1835. %    fi
  1836. %    next.extra := extra.label
  1837. %  END
  1838. % Now comes the computation for numeric labels.
  1839. % We use either the sorted order or original order.
  1840. % We still have to keep track of the longest (in width$ terms) label, for use
  1841. % by the "thebibliography" environment.
  1842. STRINGS { longest.label }
  1843. INTEGERS { number.label longest.label.width }
  1844. FUNCTION {initialize.longest.label}
  1845. { "" 'longest.label :=
  1846.   #1 'number.label :=
  1847.   #0 'longest.label.width :=
  1848. }
  1849. FUNCTION {longest.label.pass}
  1850. { number.label int.to.str$ 'label :=
  1851.   number.label #1 + 'number.label :=
  1852.   label width$ longest.label.width >
  1853.     { label 'longest.label :=
  1854.       label width$ 'longest.label.width :=
  1855.     }
  1856.     'skip$
  1857.   if$
  1858. }
  1859. EXECUTE {initialize.longest.label}
  1860. ITERATE {longest.label.pass}
  1861. % Now we're ready to start writing the .BBL file.
  1862. % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
  1863. % label; next comes stuff from the `preamble' command in the database files.
  1864. % Then we give an incantation containing the command
  1865. %     \begin{thebibliography}{...}
  1866. % where the `...' is the longest label.
  1867. %
  1868. % We also call init.state.consts, for use by the output routines.
  1869. FUNCTION {begin.bib}
  1870. { preamble$ empty$
  1871.     'skip$
  1872.     { preamble$ write$ newline$ }
  1873.   if$
  1874.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1875. }
  1876. EXECUTE {begin.bib}
  1877. EXECUTE {init.state.consts}
  1878. % Now we produce the output for all the entries
  1879. ITERATE {call.type$}
  1880. % Finally, we finish up by writing the `\end{thebibliography}' command.
  1881. FUNCTION {end.bib}
  1882. { newline$
  1883.   "\end{thebibliography}" write$ newline$
  1884. }
  1885. EXECUTE {end.bib}
  1886.